package com.ygqh.baby.observer.Observable;

import com.ygqh.baby.observer.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Observable;

/**
 * 被观察者
 * 订单支付成功
 *
 * @author (guohao)
 * @version V1.0
 * @ClassName: OrderPaySuccessObservable
 * @date 2018年7月3日 下午5:31:30
 */
@Component
public class OrderPaySuccessObservable extends Observable {

    @Autowired
    private TrustoneOrderPaidOrCancelObserver trustoneOrderPaidObserver;
    @Autowired
    private ProductBookRecordPaidOrCancelObserver productBookRecordPaidOrCancelObserver;
    @Autowired
    private ManFanCouponObserver manFanCouponObserver;
    @Autowired
    private PaySuccessMsgObserver paySuccessMsgObserver;
    @Autowired
    private InformObserver informObserver;
    @Autowired
    private WeixinGoodOrderObserver weixinGoodOrderObserver;


    @PostConstruct
    private void initObserver() {
//		this.addObserver(trustoneOrderPaidObserver);
        this.addObserver(productBookRecordPaidOrCancelObserver);
        this.addObserver(manFanCouponObserver);
        this.addObserver(paySuccessMsgObserver);
        this.addObserver(informObserver);
        this.addObserver(weixinGoodOrderObserver);
    }

    /**
     * 支付回调中调用。会通知所有观察者去处理支付成功相关业务
     *
     * @return void    返回类型
     * @throws
     * @Title: paySuccess
     * @author （guohao）
     * @date 2018年7月3日 下午5:30:48
     * @version V1.0
     */
    public void paySuccess(OrderPayModel model) {
        this.setChanged();
        this.notifyObservers(model);
    }

}
